package com.railway.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.railway.service.OrderService;
import com.railway.service.impl.OrderServiceImpl;
import com.railway.util.JSONUtil;

/**
 * Servlet implementation class SelectOrderServlet
 */
@WebServlet("/SelectOrderServlet.do")
public class SelectOrderServlet extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("Utf-8");
		int user_id = 0;
		OrderService os = new OrderServiceImpl();
		if(request.getParameter("user_id") != null && !"".equals(request.getParameter("user_id"))) {
			user_id = Integer.parseInt(request.getParameter("user_id"));
		}
		
		JSONUtil.responJSOn(response, os.selectOrderByUserId(user_id));
	}

}
